Passed
Branch master (ea9505)
by Rafael S.
01:23
created

scribe(ꞌ4-bit IMA ADPCM readingꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 62

Duplication

Lines 62
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 0
dl 62
loc 62
rs 9.4743
c 1
b 0
f 0

13 Functions

Rating   Name   Duplication   Size   Complexity  
A read-4bitIMA.js ➔ ... ➔ it(ꞌsubChunk1Size should be 20ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌsubChunk2Id should be ꞌdataꞌꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌnumChannels should be 1ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌsubChunk1Id should be ꞌfmt ꞌꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌaudioFormat should be 17 (IMA ADPCM)ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌfactChunkId should be ꞌfactꞌꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌbitsPerSample should be 4ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌformat should be ꞌWAVEꞌꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌfactChunkSize should be 4ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌsampleRate should be 8000ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌsubChunk2Size should be > 0ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌsamples.length should be > 0ꞌ) 3 3 1
A read-4bitIMA.js ➔ ... ➔ it(ꞌchunkId should be ꞌRIFFꞌꞌ) 3 3 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/*!
2
 * Wavefile
3
 * Copyright (c) 2017 Rafael da Silva Rocha.
4
 * 
5
 */
6
7 View Code Duplication
let assert = require("assert");
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8
9
describe("4-bit IMA ADPCM reading", function() {
10
11
    let fs = require("fs");
12
    let wavefile = require("../index.js");
13
    let path = "test/files/";
14
15
    let wBytes = fs.readFileSync(path + '4bit-imaadpcm-8kHz-noBext-mono.wav');
16
    let wav = new wavefile.WaveFile(wBytes);
17
18
    it("chunkId should be 'RIFF'",
19
            function() {
20
        assert.equal(wav.chunkId, "RIFF");
21
    });
22
    it("subChunk1Id should be 'fmt '",
23
            function() {
24
        assert.equal(wav.subChunk1Id, "fmt ");
25
    });
26
    it("format should be 'WAVE'",
27
            function() {
28
        assert.equal(wav.format, "WAVE");
29
    });
30
    it("subChunk1Size should be 20",
31
            function() {
32
        assert.equal(wav.subChunk1Size, 20);
33
    });
34
    it("audioFormat should be 17 (IMA ADPCM)",
35
            function() {
36
        assert.equal(wav.audioFormat, 17);
37
    });
38
    it("numChannels should be 1",
39
            function() {
40
        assert.equal(wav.numChannels, 1);
41
    });
42
    it("sampleRate should be 8000",
43
            function() {
44
        assert.equal(wav.sampleRate, 8000);
45
    });
46
    it("bitsPerSample should be 4",
47
            function() {
48
        assert.equal(wav.bitsPerSample, 4);
49
    });
50
    it("factChunkId should be 'fact'",
51
            function() {
52
        assert.equal(wav.factChunkId, 'fact');
53
    });
54
    it("factChunkSize should be 4",
55
            function() {
56
        assert.equal(wav.factChunkSize, 4);
57
    });
58
    it("subChunk2Id should be 'data'",
59
            function() {
60
        assert.equal(wav.subChunk2Id, 'data');
61
    });
62
    it("subChunk2Size should be > 0",
63
            function() {
64
        assert.ok(wav.subChunk2Size > 0);
65
    });
66
    it("samples.length should be > 0",
67
            function() {
68
        assert.ok(wav.samples_.length > 0);
69
    });
70
});
71